#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
priority_queue<pll, vector<pll>, greater<pll>> pq;
ll ans;
int n, k;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    ll w;
    cin >> w;
    pq.emplace(w, 0);
  }
  while ((pq.size() - 1) % (k - 1) != 0) pq.emplace(0, 0);
  while (pq.size() >= k) {  // k进制Huffman树
    ll depth = -1, temp = 0;
    for (int j = 1; j <= k; ++j) {
      auto [w, d] = pq.top();
      pq.pop();
      temp += w;
      depth = max(depth, d);
    }
    pq.emplace(temp, depth + 1);
    ans += temp;
  }
  cout << ans << endl << pq.top().second << endl;
  return 0;
}
